
export default class Suit {

    static readonly SPADES = new Suit('SPADES', 'S', 'Spades', '♠');
    static readonly DIAMONDS = new Suit('DIAMONDS', 'D', 'Diamonds', '♦');
    static readonly CLUBS = new Suit('CLUBS', 'C', 'Clubs', '♣');
    static readonly HEARTS = new Suit('HEARTS', 'H', 'Hearts', '♥');

    static readonly ALL_SUITS = [
        Suit.SPADES, Suit.DIAMONDS, Suit.CLUBS, Suit.HEARTS,
    ];

    readonly #name: string;
    readonly #code: string;
    readonly #title: string;
    readonly #shortTitle: string;

    constructor(name: string, code: string, title: string, shortTitle: string) {
        this.#name = name;
        this.#code = code;
        this.#title = title;
        this.#shortTitle = shortTitle;
    }

    get name(): string {
        return this.#name;
    }

    get code(): string {
        return this.#code;
    }

    get title(): string {
        return this.#title;
    }

    get shortTitle(): string {
        return this.#shortTitle;
    }

    static byName(name: string): Suit {
        return this.ALL_SUITS.find(suit => suit.name === name) as Suit;
    }
}
